package com.ruoyi.web.controller.Information;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.Information.domain.CommunityFinance;
import com.ruoyi.Information.service.ICommunityFinanceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 社区财务流水Controller
 * 
 * @author xianyu
 * @date 2025-04-04
 */
@RestController
@RequestMapping("/Information/finance")
public class CommunityFinanceController extends BaseController
{
    @Autowired
    private ICommunityFinanceService communityFinanceService;

    /**
     * 查询社区财务流水列表
     */
    @PreAuthorize("@ss.hasPermi('Information:finance:list')")
    @GetMapping("/list")
    public TableDataInfo list(CommunityFinance communityFinance)
    {
        startPage();
        List<CommunityFinance> list = communityFinanceService.selectCommunityFinanceList(communityFinance);
        return getDataTable(list);
    }

    /**
     * 导出社区财务流水列表
     */
    @PreAuthorize("@ss.hasPermi('Information:finance:export')")
    @Log(title = "社区财务流水", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CommunityFinance communityFinance)
    {
        List<CommunityFinance> list = communityFinanceService.selectCommunityFinanceList(communityFinance);
        ExcelUtil<CommunityFinance> util = new ExcelUtil<CommunityFinance>(CommunityFinance.class);
        util.exportExcel(response, list, "社区财务流水数据");
    }

    /**
     * 获取社区财务流水详细信息
     */
    @PreAuthorize("@ss.hasPermi('Information:finance:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(communityFinanceService.selectCommunityFinanceById(id));
    }

    /**
     * 新增社区财务流水
     */
    @PreAuthorize("@ss.hasPermi('Information:finance:add')")
    @Log(title = "社区财务流水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CommunityFinance communityFinance)
    {
        return toAjax(communityFinanceService.insertCommunityFinance(communityFinance));
    }

    /**
     * 修改社区财务流水
     */
    @PreAuthorize("@ss.hasPermi('Information:finance:edit')")
    @Log(title = "社区财务流水", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CommunityFinance communityFinance)
    {
        return toAjax(communityFinanceService.updateCommunityFinance(communityFinance));
    }

    /**
     * 删除社区财务流水
     */
    @PreAuthorize("@ss.hasPermi('Information:finance:remove')")
    @Log(title = "社区财务流水", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(communityFinanceService.deleteCommunityFinanceByIds(ids));
    }
}
